package com.ruyuan.ingestion.common;
import org.apache.commons.lang.ArrayUtils;
import java.util.Arrays;
public interface Parsable<T> {
    Boolean isHeader(String[] fields);
    Boolean isValid(String[] fields);

    default Boolean isEmpty(String[] fields,int[] indexes) {
        Boolean empty = false;
        if (fields !=null && fields.length > 0) {
            for (int i = 0; i< fields.length; i++) {
                //check
                if (indexes != null && ArrayUtils.contains(indexes,i)) {
                    empty |= (fields[i] == null || fields[i].trim().length() <= 0);
                }
            }
        }
        return empty;
    }
    T parse(String[] fields);
}
